* Mi Hwa Hong 
* "Legal Commitments to United Nations Human Rights Treaties and Higher Monitoring Standards in the Universal Periodic Review
* Journal of Human Rights

cd //working directory here 

use hong_jhr.dta, clear
set more off

*table 2*
*all specific recommendations: all states*
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs, cluster(dyadid)
est store model1
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs law, cluster(dyadid)
est store model2

*all specific recommendations: democracies*
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs  if auto_rs==0, cluster(dyadid)
est store model3
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs  law  if auto_rs==0, cluster(dyadid)
est store model4

*all specific recommendations: non-democracies*
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs    if auto_rs==1, cluster(dyadid)
est store model5
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs  law if auto_rs==1, cluster(dyadid)
est store model6

outreg2 [model1 model2 model3 model4 model5 model6] using table2.doc, replace word long nor2 addstat(R-squared, e(chi2), d.f., e(df_m)) 
drop _est_model1 _est_model2 _est_model3 _est_model4 _est_model5 _est_model6  

*figure 1*
*non-democratic recommending states
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs if auto_rs==1, cluster(dyadid)

capture drop coef axis lower upper
gen coef = .
gen axis = .
gen lower = .
gen upper = .

margins, at(hra_9core_rs = (0 9)) 


matrix m = r(V)
local se = sqrt(m[1,1])
matrix m = r(b)
local b = m[1,1]
replace axis = 1 if _n == 1
replace coef = `b' if _n == 1
replace upper = `b' + 1.96*`se' if _n == 1
replace lower = `b' - 1.96*`se' if _n == 1

matrix m = r(V)
local se = sqrt(m[2,2])
matrix m = r(b)
local b = m[1,2]
replace axis = 2 if _n == 2
replace coef = `b' if _n == 2
replace upper = `b' + 1.96*`se' if _n == 2
replace lower = `b' - 1.96*`se' if _n == 2


#delimit ;
twoway rcap lower upper axis if axis < 4, color(gs8)
  || scatter coef axis if axis < 4, color(gs8)
  msymbol(smplus) msize(vtiny)
  xlabel(1 "lower commitment" 2 "higher commitment")
  ytitle("predicted probability") yline(0, lstyle(foreground))
  xtitle("recommending state's commitment to human rights treaties")
  legend(off)
  xscale(range(.5 2.5))
  yscale(range(0 .4))
  ylabel(0(.1) .5)
  msize(*2.5)
  ylabel(,grid)
  scheme(burd) plotregion(style(none)) 
  ;
#delimit cr

*non-democratic states under review
logit costly hra_9core_rs hra_9core_sur polity2_rs polity2_sur lngdp_rs if auto_rs==1, cluster(dyadid)

capture drop coef axis lower upper
gen coef = .
gen axis = .
gen lower = .
gen upper = .

margins, at(hra_9core_sur = (0 9)) 

matrix m = r(V)
local se = sqrt(m[1,1])
matrix m = r(b)
local b = m[1,1]
replace axis = 1 if _n == 1
replace coef = `b' if _n == 1
replace upper = `b' + 1.96*`se' if _n == 1
replace lower = `b' - 1.96*`se' if _n == 1

matrix m = r(V)
local se = sqrt(m[2,2])
matrix m = r(b)
local b = m[1,2]
replace axis = 2 if _n == 2
replace coef = `b' if _n == 2
replace upper = `b' + 1.96*`se' if _n == 2
replace lower = `b' - 1.96*`se' if _n == 2


#delimit ;
twoway rcap lower upper axis if axis < 4, color(gs8)
  || scatter coef axis if axis < 4, color(gs8)
  msymbol(smplus) msize(vtiny)
  xlabel(1 "lower commitment" 2 "higher commitment")
  ytitle("predicted probability") yline(0, lstyle(foreground))
  xtitle("reviewed state's commitment to human rights treaties")
  legend(off)
  xscale(range(.5 2.5))
  yscale(range(0 .4))
  ylabel(0(.1) .5)
  msize(*2.5)
  ylabel(,grid)
  scheme(burd) plotregion(style(none)) 
  ;
#delimit cr

save hong_jhr.dta, replace



